package hate.controller;


import hate.model.Person;


import io.ebean.EbeanServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RestController
@EnableAutoConfiguration
@RequestMapping("/person")
public class PersonController {

    @Autowired
    private EbeanServer ebeanServer;

    @RequestMapping(value = "/getPersonById/{id}" ,method = RequestMethod.GET)
    @ResponseBody
    public Person getPersonByid(int id){

        return ebeanServer.find(Person.class,id);
    }

    @RequestMapping(value = "/getPersonAll",method = RequestMethod.GET)
    @ResponseBody
    public List<Person> getPersonAll(){
        return ebeanServer.find(Person.class).findList();
    }


    @ResponseBody
    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    public String hello3() {
       // System.out.println("id:" + id + " name:" + name);
        return "哈特计算机";
    }



}
